import { Navigate, useRoutes } from 'react-router-dom'
import Main from "../components/Main";
import Login from "../components/Login";
import NotFund from "../components/404";
import Home from "../components/Main/Home";
import About from "../components/Main/About";



const routes = [
  {
    path: '/login',
    element: <Login />
  },
  {
    path: '/main',
    element: <Main />,
    children: [
      {
        path: '/main/about',
        element: <About />
      },
      {
        path: '/main/home',
        element: <Home />
      },
    ]
  },
  {
    path: '/',
    element: <Navigate to='/login' />
  },
  {
    path: '*',
    element: <NotFund />
  }

]

export default routes

//定义组件
export const GetRoutes = () => {
  return useRoutes(routes)
}

//自定义Hook
export const useMyRoutes = () => {
  return useRoutes(routes)
}